import {Config} from '../Config'
const Storage = window.localStorage || window.sessionStorage;

//封装浏览器存储时所需方法


//设置缓存某一个key
export async function setStorageItem(key, value) {
    return Storage.setItem(key,value);
}
//获取某一个key的缓存
export function getStorageItem(key) {
    return Storage.getItem(key);
}
//移除某一个key的缓存
export function removeStorageItem(key) {
    return Storage.removeItem(key);
}

//清楚全部缓存
export function clearStorage() {
    return Storage.clear();
}

//异步设置缓存Token
export async function setToken(value) {
    Storage.setItem(Config.tokenKey,value);
}

//获取Token
export function getToken(){
    return Storage.getItem(Config.tokenKey) || '';
}

//异步移除Token
export  async function removeToken(){
    return Storage.removeItem(Config.tokenKey);
}

